#include "timer_list.h"
#include <stdio.h>
#include "module.h"


typedef struct
{
    int (*callback)(void *arg);
    void *arg;
    unsigned long time;
    unsigned int mode;
}TIMER_OBJ_t;

static TIMER_OBJ_t timer_obj[32];

int timer_create(int (*callback_func)(void *arg), void *arg, unsigned long time, unsigned int mode)
{
    int ii;
    for (ii=0; ii<128; ii ++)
    {
        if (timer_obj[ii].callback == NULL)
        {
            timer_obj[ii].callback = callback_func;
            timer_obj[ii].arg = arg;
            timer_obj[ii].mode = mode;
            timer_obj[ii].time = time;
            return 0;
        }
    }
    return -1;
}

int Timer_init()
{
    printf("timer_init\r\n");

  
    
    
}

int Timer_run(void *arg)
{
    int ii;
    int count = 0;
    for (ii=0; ii<128; ii ++)
    { 
        if (timer_obj[ii].callback)
            count ++;
    }  
    printf("current timer cnt=%d\r\n", count);
}

int Timer_close() 
{
    printf("test_close\r\n");
}

module_init(Timer)

